<%@ page language="java" contentType="text/html; charset=UTF-8" %>
   
    <!-- 页首-->
    <%@ include file="/WEB-INF/views/commons/header.jsp" %>

        <!--main wrapper-->
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <!-- 左侧菜单 -->
            <%@ include file="/WEB-INF/views/commons/leftMenu.jsp" %>

                <!-- 正文 -->
                <aside class="right-side">
                    <!-- 正文 头-->
                    <section class="content-header">
                        <h1>
                        现金管理
                    </h1>
                        <ol class="breadcrumb">
                            <li><a href="${ctx}/main"><i class="fa fa-home"></i> 首页</a>
                            </li>
                            <li class="active">现金管理</li>
                        </ol>
                    </section>

                    <!-- 内容-->
                    <section class="content">
                        <h3 class="row">
                            <div class="col-md-3">昨日结存: <span class="label label-info"><i class="ion ion-social-usd"></i><label id="cashLast">${company.cashLast}</label></span></div>
                            <div class="col-md-3">当前结存: <span class="label label-info"><i class="ion ion-social-usd"></i><label id="cashToday">${company.cashToday}</label></span></div>
                            <div class="col-md-3">今日收入：<span class="label label-success"><i class="ion ion-plus-round"></i><label id="cashPlus">${company.cashPlus}</label></span></div>
                            <div class="col-md-3">今日支出：<span class="label label-danger"><i class="ion ion-minus-round"></i><label id="cashMinus">${company.cashMinus}</label></span></div>
                        </h3>
                        
                        <div class="row" style="margin-top:20px;">
                          <div class=" col-md-6">
                           <div class="box box-info">
                                <div class="box-header">
                                    <h3 class="box-title">今日现金收入明细 </h3>
                                    <div class="box-tools pull-right">
                                        <button class="btn btn-success" id="plusCash" rel="#overlay"  ><i class="fa fa-plus-circle"></i>存入现金</button>

                                    </div>
                                </div>

                                <div class="box-body cash-body">
                                    <ul class="todo-list" id="addCashTable" >
                                       <c:forEach var="cash" items="${plusList}"> 
                                            <li> ${cash.remark}
                                                <strong  class="text-red"><i class="ion ion-plus-round"></i>${cash.money}</strong>
                                                <small class="text-muted pull-right">${cash.operatorName} <fmt:formatDate value="${cash.createTime}" pattern="HH:mm:ss"/> </small>
                                            </li>
                                               
                                        </c:forEach>
                                       
                                        
                                    </ul>
                                   
                                   
                                
                                </div>
                            </div> 
                            </div>
                              <div class=" col-md-6 ">
                            <div class="box box-info col-md-6">
                                <div class="box-header">
                                    <h3 class="box-title">今日现金支出明细 </h3>
                                    <div class="box-tools pull-right">
                                        <button class="btn btn-success" id="minusCash" rel="#overlay"  ><i class="fa fa-minus-circle"></i>支取现金</button>

                                    </div>
                                </div>

                                <div class="box-body cash-body">
                                   
                                   <ul class="todo-list" id="drawCashTable">
                                         <c:forEach var="cash" items="${minusList}"> 
                                            <li> ${cash.remark}
                                                <strong  class="text-red"><i class="ion ion-minus-round"></i>${cash.money}</strong>
                                                <small class="text-muted pull-right">${cash.operatorName} <fmt:formatDate value="${cash.createTime}" pattern="HH:mm:ss"/> </small>
                                            </li>
                                               
                                        </c:forEach>
                                        
                                        
                                    </ul>
                                   
                                </div>
                            </div> 
                            </div>
                        </div>
                        
   

                    </section>
                    <!-- 内容结束 -->
                </aside>
        <!-- 内容结束 -->
        </div>
     
           
            
        <!-- 页尾-->
        <%@ include file="/WEB-INF/views/commons/end.jsp" %>
            
        <script>
             $(function() {
                function flushCompany(company){
                     $('#cashLast').text(company.cashLast);
                     $('#cashToday').text(company.cashToday);
                     $('#cashPlus').text(company.cashPlus);
                     $('#cashMinus').text(company.cashMinus);
                }
                 
                 $('.cash-body').slimScroll({height: '400px'});
                
                $('#plusCash').overlyDailog({
                     title:'存放现金',
                     url:'${ctx}/cash/plus',
                     size:4,
                     berforeClose:function(is_ok,f){
                        if(is_ok){
                            $.ajax({
                                url:'${ctx}/cash/plus',
                                data:f,
                                success:function(ret){
                                    flushCompany(ret.company);
                                     var time =  new Date(ret.cash.createTime);
                                    var html = '<li>'+ret.cash.remark +' '
                                              +'<strong  class="text-red"><i class="ion ion-plus-round"></i>'
                                              +ret.cash.money
                                              +'<small class="text-muted pull-right">'
                                                +ret.cash.operatorName +' '
                                             +time.getHours()+':'+time.getMinutes()+':'+time.getSeconds()
                                              +'</small></li>'
                                    
                                    $('#addCashTable').prepend(html);
                                }
                            });
                        }
                     }
                });
                 
                $('#minusCash').overlyDailog({
                     title:'支取现金',
                     url:'${ctx}/cash/minus',
                     size:4,
                     berforeClose:function(is_ok,f){
                        if(is_ok){
                             $.ajax({
                                url:'${ctx}/cash/minus',
                                data:f,
                                success:function(ret){
                                     flushCompany(ret.company);
                                    var time =  new Date(ret.cash.createTime);
                                    
                                    var html = '<li>'+ret.cash.remark +' '
                                              +'<strong  class="text-red"><i class="ion ion-minus-round"></i>'
                                              +ret.cash.money
                                              +'<small class="text-muted pull-right">'
                                              +ret.cash.operatorName +' '
                                              +time.getHours()+':'+time.getMinutes()+':'+time.getSeconds()
                                              +'</small></li>'
                                    
                                    $('#drawCashTable').prepend(html);
                                }
                            });
                        }
                     }
                });
                 
                 
               
                 
                  
            });
        
        </script>
     